<?php

class model_wishBuyAccount extends L {

    /**
     * 描述 ：分页的查询语句拼接
     * 作者 ：Zoro.Zhu
    **/
    public static function searchSql($params = array()){
        $sql = "SELECT
             `id`, `account`, `cookie`, `token`, `xToken`, `vsAccount`, `updDate`
        FROM
            `wish_buy_account`
        WHERE 1";

        $sql .= " AND vsAccount = '" . core_base::getUser('name') ."'";
        $sql .= !empty($params['search']['account']) ? " AND `account` LIKE '%{$params['search']['account']}%' " : "";
        return $sql;
    }

    /**
     * 描述 ：执行修改数据的sql
     * 作者 ：Zoro.Zhu
    **/
    public static function updateSql($data = array()){
        $sql = "UPDATE `wish_buy_account` 
        SET 
            `account` = '{$data['account']}',
            `cookie` = '{$data['cookie']}',
            `token` = '{$data['token']}',
            `xToken` = '{$data['xToken']}',
            `vsAccount` = '{$data['vsAccount']}',
            `updDate` = '{$data['updDate']}'
        WHERE
            `id` = '{$data['id']}'";
        return L::sql($sql);
    }

    /**
     * 描述 ：执行插入数据的sql
     * 作者 ：Zoro.Zhu
    **/
    public static function insertSql($data = array()){
        $sql = "INSERT INTO `wish_buy_account`(
             `account`, `cookie`, `token`, `xToken`, `vsAccount`, `updDate`
        ) VALUES (
             '{$data['account']}', '{$data['cookie']}', '{$data['token']}', '{$data['xToken']}', '{$data['vsAccount']}', '{$data['updDate']}'
        )";
        return L::sql($sql);
    }

    /**
     * 描述：根据主键获取数据
     * 作者：Zoro.Zhu
    **/
    public static function getKeyInfo($key){
        $sql = "SELECT
             `id`, `account`, `cookie`, `token`, `xToken`, `vsAccount`, `updDate`
        FROM
            `wish_buy_account`
        WHERE 
            `id` = '{$key}'";
        return L::sql($sql);
    }

    /**
     * 描述：根据条件获取数据
     * 作者：Zoro.Zhu
     **/
    public static function getParamsInfo($params = null, $select = []){
        if(empty($select)){
            $s = 'id`, `account`, `cookie`, `token`, `xToken`, `vsAccount`, `updDate';
        }else{
            $s = join("`,`", $select);
        }
        $sql = "SELECT
              `{$s}` 
        FROM
            `wish_buy_account`
        WHERE 
            1";
        if(!empty($params)){
            foreach($params as $k => $v){
                $sql .= " AND `{$k}` = '{$v}'";
            }
        }
        return L::sql($sql);
    }

}